package com.library.web.sys_book.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.library.web.sys_book.mapper.SysBooksMapper;
import com.library.web.sys_book.pojo.BookVo;
import com.library.web.sys_book.pojo.ListParm;
import com.library.web.sys_book.pojo.SysBooks;
import com.library.web.sys_book.pojo.ExportVo;
import com.library.web.sys_book.service.SysBooksService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysBooksServiceImpl extends ServiceImpl<SysBooksMapper, SysBooks> implements SysBooksService {
    @Override
    public IPage<SysBooks> getList(ListParm listParm) {
        //构造分页对象
        Page<SysBooks> page = new Page();
        page.setCurrent(listParm.getCurrentPage());
        page.setSize(listParm.getPageSize());
        return this.baseMapper.getList(page, listParm);
    }

    //减库存
    @Override
    public Integer subBook(Long bookId) {
        return this.baseMapper.subBook(bookId);
    }

    @Override
    public int addBook(Long bookId) {
        return this.baseMapper.addBook(bookId);
    }

    //热门图书
    @Override
    public List<BookVo> getHotBook() {
        return this.baseMapper.getHotBook();
    }

    //周图书排行
    @Override
    public List<BookVo> getBookByWeek() {
        return this.baseMapper.getBookByWeek();
    }

    //月图书排行
    @Override
    public List<BookVo> getBookByMonth() {
        return this.baseMapper.getBookByMonth();
    }

    //导出图书
    @Override
    public List<ExportVo> exportBook() {
        return this.baseMapper.exportBook();
    }

}
